namespace go api

/*设备控制命令类型*/
enum ControlCmdType {
    RESPONSE_CMD,    /*有应答控制*/
    NO_RESPONSE_CMD, /*无应答控制*/
}

/*订阅事件类型*/
enum SubscribeType {
    CATALOG_EVENT,    /*目录订阅*/
    ALARM_EVENT,      /*报警事件订阅*/
    MOBILE_POS_EVENT, /*移动设备位置通知事件*/
}

/*报警级别*/
enum AlarmPriority {
    PRIMARY_LEVEL_ALARM = 1,
    SECONDARY_LEVEL_ALARM,
    THRID_LEVEL_ALARM,
    FOUR_LEVEL_ALARM,
}

/*报警方式*/
enum AlarmMethod {
    PHONE_ALARM = 1,
    DEVICE_ALARM,
    SMS_ALARM,
    GPS_ALARM,
    VIDEO_ALARM,
    DEVICE_FAULT_ALARM,
    OTHER_ALARM,
}

/*设备连接*/
struct DeviceConnectRequest {
    1: string nvrSipId,
    2: i32 channel,
    3: string mediaCenterIP,
    4: i32 mediaCenterPort,
    5: string app,
    6: string stream,
    7: string time,          /*校时参数：Date:yyyy-MM-dd'T'HH:mm:ss.SSS*/
    8: string tid,
}

/*设备断开连接*/
struct DeviceDisConnectParam {
    1: string nvrSipId,
    2: i32 channel,
    3: string tid,
}

/*心跳检测*/
struct HeartBeatCallbackParam {
    1: string ip,
    2: i32 port,
    3: i16 interval,
    4: i16 maxTimeOut,
    5: string tid,
}

/*实时预览*/
struct RealPlayParam {
    1: string nvrSipId,
    2: i32 channel,
    3: string mediaCenterIP,
    4: i32 mediaCenterPort,
    5: string tid,
}

/*视音频历史回放*/
struct PlayBackParam {
    1: string nvrSipId,
    2: i32 channel,
    3: string mediaCenterIP,
    4: i32 mediaCenterPort,
    5: string beginTime,
    6: string endTime,
    7: i16 streamId,
    8: i64 channelId,
    9: string tid,
}

/*缩放控制*/
struct DragZoom {
    1: i64 Length,
    2: i64 Width,
    3: i64 MidPointX,
    4: i64 MidPointY,
    5: i64 LengthX,
    6: i64 WidthY,
}

/*设备控制*/
struct DeviceControl {
    1: ControlCmdType cmdType,
    2: string cmdSerialNum,
    3: string nvrSipId,
    4: i32 channel,
    5: DragZoom dragZoomIn,
    6: DragZoom dragZoomOut,
    7: string subMessage,
    8: string tid,
}

/*报警事件*/
struct AlarmEvent {
    1: string cmdType,       /*命令类型*/
    2: string cmdSn,         /*命令序列号*/
    3: string nvrSipId,      /*目标设备编码*/
    4: i32 channel,
    5: string alarmPriority, /*报警级别*/
    6: string alramTime,     /*报警时间*/
    7: string alarmMethod,   /*报警方式*/
    8: string Longitude,     /*经度*/
    9: string Latitude,      /*纬度*/
    10: string alarmType,    /*报警类型*
    11:  string alarmTypeParam, /*报警类型参数*/
}

/*设备信息*/
struct DeviceInfo {
    1: string nvrSipId,           /*设备ID*/
    2: string deviceName,         /*设备名称*/
    3: string result,             /*查询结果*/
    4: string manufacturer,       /*生产厂商*/
    5: string model,              /*设备型号*/
    6: string firmware,           /*固件版本*/
    7: i64 maxNumOfCameraSupport, /*最大支持摄像机个数*/
}

/*设备状态信息*/
struct DeviceStatusInfo {
    1: string result,     /*查询结果*/
    2: bool bOnline,      /*是否在线*/
    3: i16 status,        /*设备工作状态*/
    4: string reason,     /*不正常原因*/
    5: bool bEncode,      /*是否编码*/
    6: bool bRecord,      /*是否录像*/
    7: string deviceTime, /*日期和时间*/
    8: string dutyStatus, /*报警设备状态*/
}

/*通用答复*/
struct CommonResponse {
    1: i32 code,
    2: string msg,
}

/*设备类型*/
enum DeviceType {
    HAIKANG,
    DAHUA,
    YUSHI,
}

enum DeviceConnectType {
    RTSP,
    SDK,
}

struct ChannelInfo {
    1: i32 channelIndex,  /*通道号*/
    2: string cameraName, /*摄像头名称*/
    3: bool isAvailable,  /*是否可用*/
    4: i32 streamType,    /*0-主码流，1-子码流，2-3码流，3-虚拟码流4，以此类推*/
    5: i32 linkMode,      /*0- TCP方式，1- UDP方式，2- 多播方式，3- RTP方式，4-RTP/RTSP，5-RSTP/HTTP*/
    6: i32 protoType,     /*取流协议 0- 私有协议(默认)，1- RTSP协议*/
}

/*设备接入信息*/
struct DeviceSetupHelpInfoResponse {
    1: string deviceRawId,               /*设备厂家ID*/
    2: string rtspUrl,                   /*视频推流的RTSP Url*/
    3: i32 channelCount,                 /*通道数量*/
    4: list<ChannelInfo> allChannelInfo, /*nvr对应的通道信息*/
    5: bool isSDKTestPass,               /*配置的SDK库是否适配*/
}

/*设备接入信息*/
struct NvrSetupRequest {
    1: string nvrSipId,               /*设备国标ID*/
    2: string deviceRawId,            /*设备厂家ID*/
    3: DeviceConnectType connectType, /*视频推流的方式*/
    4: string rtspUrl,                /*视频推流的RTSP Url*/
    5: string deviceIp,               /*IP地址*/
    6: i32 devicePort,                /*连接端口*/
    7: string userName,               /*用户名*/
    8: string userPassword,           /*密码*/
    9: i32 channelCount,              /*通道数量*/
    10: DeviceType deviceType,        /*设备类型*/
    11: string sdkVersion,            /*设备对应的sdk版本号*/
    12: i32 streamType,               /*0-主码流，1-子码流，2-3码流，3-虚拟码流4，以此类推*/
    13: i32 linkMode,                 /*0- TCP方式，1- UDP方式，2- 多播方式，3- RTP方式，4-RTP/RTSP，5-RSTP/HTTP*/
    14: i32 protoType,                /*取流协议 0- 私有协议(默认)，1- RTSP协议*/
    15: string tid,                   /*事务ID*/
}

/*获取备用的设备接入信息*/
struct DeviceSetupHelpInfoRequest {
    1: DeviceType deviceType, /*设备类型*/
    2: string deviceIp,       /*IP地址*/
    3: i32 devicePort,        /*连接端口*/
    4: string userName,       /*用户名*/
    5: string userPassword,   /*密码*/
    6: i32 startChannel,      /*通道起始号，一般为1或者33*/
    7: string sdkVersion,     /*设备对应的sdk版本号*/
    8: string tid,            /*事务ID*/
}

/*获取备用的设备接入信息*/
struct ConnectDeviceResponse {
    1: i32 code,
    2: string msg,
    3: string playUrl,
}

/**设备SKD封装*/
service sipSvr {

    /**获取备用的设备接入信息*/
    DeviceSetupHelpInfoResponse getDeviceSetupHelpInfo(1: DeviceSetupHelpInfoRequest param),

    /**添加或者修改设备连接信息*/
    CommonResponse setupDevice(1: NvrSetupRequest param),

    /**连接设备，设备被动连接，非国标*/
    ConnectDeviceResponse connectDevice(1: DeviceConnectRequest param),

    /**设备断开连接，设备被动连接，非国标*/
    CommonResponse disConnectDevice(1: DeviceDisConnectParam param),

    /**设置回调，接入中心将向回调的地址端口转发心跳信息*/
    CommonResponse setHeartBeatCallback(1: HeartBeatCallbackParam param),

    /*历史视音频回放*/
    ConnectDeviceResponse playBackByTime(1: PlayBackParam param),

    /*设备控制*/
    CommonResponse deviceControlCmd(1: DeviceControl ctrl),

    /*报警事件分发和通知*/
    AlarmEvent alarmEventNotifyAndDispatcher(1: string tid),

    /*设备信息查询*/
    DeviceInfo deviceInfoQuery(1: string nvrSipId, 2: string tid),

    /*设备状态信息查询*/
    DeviceStatusInfo deviceStatusInfoQuery(1: string nvrSipId, 2: string tid),

    /*订阅事件*/
    CommonResponse subscribeEvent(1: SubscribeType subType, 2: string tid),

    /*通知事件*/
    CommonResponse NotifyEvent(1: SubscribeType subType, 2: string tid),
}